<?php
class AdminController extends Zend_Controller_Action {
	private $book;
	
	public function init() {
		$this->book = new Book();
	}
	
	
	public function viewpendingbooksAction() {
		if ($this->_helper->user->isLoggedIn()) {
	    	$user = $this->_helper->user->getUserData();
	    	if (User::hasAccessRight($user, AccessRight::ADMIN)) {
	        	$config = Zend_Registry::get("config");
	        	$baseurl = $config->baseurl;
	            $books = $this->book->findAllPending();
	            $this->view->pendingBooks = $books;
	            $this->view->baseurl = $baseurl;
	    	} else {
	    		throw new Exception("User don't have permission to access admin");
	    	}
        } else {
            $this->_redirect( "/user/login?next=".urlencode($this->_helper->generator->getCurrentURI()) );
        }
	}
}
?>